package com.cy.login.controller;

import com.cy.login.comment.core.ResponseResult;
import com.cy.login.domain.Account;
import com.cy.login.domain.Server;
import com.cy.login.service.ServerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 服务器列表(Server)表服务控制层
 *
 * @author cxy
 * @since 2024-07-10 15:04:36
 */
@Api(tags = "服务器列表(Server)") 
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/server")
public class ServerController {
    @Resource
    private final ServerService serverService;

    @ApiOperation("获取服务器列表，必须携带token")
    @PostMapping("/proLogListJson")
    public ResponseResult<List<Server>> proLogListJson(@RequestHeader String token) {
        return ResponseResult.success(serverService.proLogListJson(token));
    }

    @ApiOperation("进入服务器(获取游戏服务器token)，必须携带token和游戏服务器url")
    @PostMapping("/enterServer")
    public ResponseResult<String> enterServer(@RequestHeader String token,@Valid @RequestBody Server server) {
        return ResponseResult.success(serverService.enterServer(token, server.getUrl()));
    }

}
